package com.jhy.study2.thread;

public class Actor extends Thread {



    @Override
    public void run() {
        Integer count = 0;
        System.out.println(getName()+ "开始运行了");


        Boolean keepRunning = true;


        try {
            while(keepRunning){
                //每隔10的整倍数休眠2秒
                if(count%10 == 0){
                    Thread.sleep(2000);
                }

                System.out.println(getName()+ "执行-->" + (++count));

                if(count == 100){
                    break;
                }

            }

        } catch (Exception e) {
            e.printStackTrace();
        }
        System.out.println(getName()+ "运行结束");
    }

    public static void main(String[] args) {

        Actor actor1 = new Actor();
        actor1.setName("小样");
        actor1.start();
        new Thread(new Actor2()).start();
    }


}


class Actor2 implements Runnable{

    @Override
    public void run() {
        Thread.currentThread().setName("死鬼");
        Integer count = 0;
        System.out.println(Thread.currentThread().getName()+ "开始运行了");


        Boolean keepRunning = true;


        try {
            while(keepRunning){
                //每隔10的整倍数休眠2秒
                if(count%10 == 0){
                    Thread.sleep(2000);
                }

                System.out.println(Thread.currentThread().getName()+ "执行-->" + (++count));

                if(count == 100){
                    break;
                }

            }

        } catch (Exception e) {
            e.printStackTrace();
        }
        System.out.println(Thread.currentThread().getName()+ "运行结束");
    }



}





/*
*
* 下面的这个类这是 证明了接口里的方法 带不带abstract修饰的，继承类都需要实现这些方法
* */

class Actor00 implements  Interface1{

    @Override
    public void speak(String str) {

    }

    @Override
    public void talk(String str) {

    }
}






